<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
	<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
	<meta name="apple-mobile-web-app-capable" content="yes"/>
	<title>test Opener with Calendar</title>

	<link href="../../../dijit/themes/dijit.css" rel="stylesheet"/>
	<script type="text/javascript" src="../deviceTheme.js" data-dojo-config="mblThemeFiles: ['base','Overlay','Tooltip','dijit.Calendar']"></script>
	<script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true"></script>

	<script language="JavaScript" type="text/javascript">
		require([
			"dojo/ready",
			"dojo/dom-construct",
			"dojox/mobile",
			"dojox/mobile/Opener",
			"dojox/mobile/ToolBarButton",
			"dojox/mobile/Heading",
			"dojox/mobile/compat",
			"dojox/mobile/parser",
			"dijit/_base/manager" // dijit.byId
		], function(ready, domConstruct, mobile, Opener, ToolBarButton, Heading, manager){
			ready(function(){
				var opener = new Opener({onHide:getDate2, onShow:setDate2, lazy:true}, "calPicker");
				var headingNode = domConstruct.create("div", {dojoType:"dojox.mobile.Heading", label:"Dates"}, opener.domNode);
				domConstruct.create("div", {dojoType:"dojox.mobile.ToolBarButton", label:"Done", style:"position:absolute;width:40px;right:0;", onclick:"dijit.byId('calPicker').hide(true)"}, headingNode);
				domConstruct.create("div", {dojoType:"dojox.mobile.ToolBarButton", label:"Cancel", style:"position:absolute;width:40px;left:0;", onclick:"dijit.byId('calPicker').hide(false)"}, headingNode);
				domConstruct.create("div", {dojoType:"dijit.CalendarLite", id:"cal"}, opener.domNode);
			});
		});

		function getDate2(node, v){
			if(v === true){ // Done clicked
				var w = dijit.byId("cal");
				var date;
				try {
					date = w.get("value");
				} catch (e) {
					return;
				}
				node.value = date;
			}
		}
		function setDate2(node){
			var v = node.value.split(/-/);
			if(v.length == 3){
				var w = dijit.byId("cal");
				w.setValue(v);
			}
		}
	</script>

	<style>
		html, body{
			overflow: hidden;
		}
		.mblTooltip.mblOpener DIV[label='Cancel'] {
			display: none;
		}
	</style>
</head>
<body style="visibility:hidden;">
	<table cellspacing="20">
	<tr>
		<td style="text-align:right;">Date</td>
		<td><input id="date3" readOnly value=""
			onclick="dijit.byId('calPicker').show(this, ['above-centered','below-centered','after','before'])"></td>
	</tr>
	</table>
	<div id="calPicker"></div>
</body>
</html>
